<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <title>微信安全支付</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">

	<script type="text/javascript">
		
		//调用微信JS api 支付
		function jsApiCall()
		{
			WeixinJSBridge.invoke(
				'getBrandWCPayRequest',
				<?php echo $jsApiParameters; ?>,
				function(res){
					WeixinJSBridge.log(res.err_msg);
				//alert(res.err_code+res.err_desc+res.err_msg);
					if(res.err_msg == 'get_brand_wcpay_request:ok'){
						// 支付成功   调用成功页面
						if("<?php echo $order['team_number']?>"){
							// model_type 支付成功后返回的活动类型
                            // pay_status 支付成功后返回的支付状态
 							window.location.href='/user/action/info?store_id=<?php echo $order["store_id"];?>&barber_id=<?php echo $order["barber_id"];?>&aid=<?php echo $order["action_id"];?>&team_number=<?php echo $order["team_number"]?>&pay_status=ok&model_type=<?php echo $model_type; ?>&headimg=<?php echo $headimg; ?>&nickname=<?php echo $nickname; ?>';
						}else{
							window.location.href= "<?php echo shop_buildUrl('/user/shop/payStatus?status=1'); ?>";
						}
					}
				}
			);
		}

		function callpay()
		{
			if (typeof WeixinJSBridge == "undefined"){
			    if( document.addEventListener ){
			        setTimeout(document.addEventListener('WeixinJSBridgeReady', jsApiCall, false));
			    }else if (document.attachEvent){
			        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
			        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
			    }
			}else{
			    jsApiCall();
			}
		}
		window.onload=function()//用window的onload事件，窗体加载完毕的时候
		{
		   callpay();
		}
	</script>
</head>
<body>
</body>
</html>
